<?php
class Blogs extends CI_Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function __construct()
    {
    	
        parent::__construct();
        
    }
    
	function getList($page){
		$page=$page?$page:0;
    	$limit=($page*20).','.'20';
		$query= $this->db->query("select * from news_news LIMIT $limit");
        return $query->result();
    }
	
	function getInfoById($id)
    {
		$this->db->where('id',$id);
		$query = $this->db->get('blogs');
		//var_dump($query->result());
		$rs=$query->result();
        return $rs[0];
		//echo 11111111111111;
    }
	
	function insert_entry()
    {
        $this->title   = $_POST['title']; // 请阅读下方的备注
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->insert('blogs', $this);
    }

    function update_entry()
    {
        $this->title   = $_POST['title'];
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->update('blogs', $this, array('id' => $_POST['id']));
    }

    

}
